<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>

	<head>
		<title>业务处理-入库管理-领料归还</title>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>libs/bootstrap-3.3.7-dist/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>css/reset.css">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>css/style.css">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>css/iframe.css">
	</head>

	<body>
		<header id="mainHeader"></header>
		<div id="mainContent">
			<div id="mainContent_content">
				<div class="page_header">
					<a>领料归还</a>
				</div>
				<div class="search">
					<form action="<%=basePath%>pickingReturnContrlooer/selectByWhere.do" method="post" class="form">
						<input type="hidden" name="currentPage" value="1">
						<p>

							<label>归还单号</label>
							<input class="form-control" type="text" name="pickingreturnNumber" value="${pickingReturnPage.pickingreturnNumber }"></input>

							<label> 时间</label>
							<input class="form-control" type="text" name="starttime" value="${pickingReturnPage.starttime }" readonly onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})"></input>

							<label>至</label>
							<input class="form-control" type="text" name="endtime" value="${pickingReturnPage.endtime }" readonly onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})"></input>

							<label>创建人</label>
							<input class="form-control" type="text" name="subname" value="${pickingReturnPage.subname }"></input>

							<label>仓库</label>
							<select name="warehouseID" class="form-control select">
								<option value="">全部</option>
								<c:forEach items="${wm }" var="w">
									<option value="${w.warehousemanagementid }" <c:if test="${pickingReturnPage.warehouseID==w.warehousemanagementid}">selected</c:if>>${w.warehousename }</option>
								</c:forEach>
							</select>

						</p>
						<p>

							<label>入库说明</label>
							<input type="text" class="form-control doubleWidth" name="company" value="${pickingReturnPage.company }"></input>

							<span class="btn">
							<input type="submit" value="搜索" class="btn btn1"></input>
							<input type="button" value="清空" onclick="clearSearchParam();"  class="btn btn2"></input>
							<input type="button" value="新增" onclick="location.href='<%=basePath%>pickingReturnContrlooer/toAdd.do'"  class="btn btn1"></input>
							
							<input type="button" class="btn btn2" value="下载PDF" onclick="window.open('<%=basePath %>pickingReturnContrlooer/downloads.do?warehouseNumber=${w.warehousenumber }');"></input>
						</span>
						</p>
					</form>
				</div>
				<div class="tableBox box">
					<table class="table table-bordered table_text_center">
						<thead>
							<tr>
								<th>序号</th>
								<th>操作</th>
								<th>领料归还入库单号</th>
								<th>入库说明</th>
								<th>仓库</th>
								<th>创建时间</th>
								<th>创建人</th>
								<th>状态</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${pickingReturnList }" var="p" varStatus="i">
								<tr>
									<td>${i.index+1 }</td>
									<td>
										<c:if test="${p.status==0 }">
											<a class="btn btn-xs btn1" onclick="location.href='<%=basePath%>pickingReturnContrlooer/toUpdate.do?pickingreturnID=${p.pickingreturnID }'">编辑</a>
											<a class="btn btn-xs btn_danger" onclick="deletePickingreturn(${p.pickingreturnID });">删除</a>
										</c:if>
										<c:if test="${p.status==1 }">
											<a class="btn btn-xs btn1" onclick="location.href='<%=basePath%>pickingReturnContrlooer/toDetailspickingReturn.do?pickingreturnID=${p.pickingreturnID }'">查看</a>
										</c:if>
									</td>
									<td>${p.pickingreturnNumber }</td>
									<td>${p.company }</td>
									<td>${p.warehouseName }</td>
									<td>
										<fmt:formatDate value='${p.createTime }' type='date' />
									</td>
									<td>${p.createPerson }</td>
									<td>${p.status==0?"未提交":"已提交"}</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
				<jsp:include page="/jsp/basic/page.jsp"></jsp:include>

			</div>
			<jsp:include page="/jsp/basic/prompt.jsp"></jsp:include>
		</div>
		<script src="<%=basePath%>js/jquery-3.2.1.min.js"></script>
		<script src="<%=basePath%>libs/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
		<script src="<%=basePath%>My97DatePickers/WdatePicker.js"></script>
		<script src="<%=basePath%>js/public.js"></script>
		<script type="text/javascript">
			//清空搜索条件
			function clearSearchParam() {
				$(".search input:text").val("");
				$(".search select").val("");
			}
			//删除未提交的领料归还信息
			function deletePickingreturn(pickingreturnID) {
				var delFunc = function() {
					$.ajax({
						url: "<%=basePath%>pickingReturnContrlooer/deletePickingreturn.do",
						type: "post",
						async: false,
						dataType: "json",
						data: "pickingreturnID=" + pickingreturnID,
						success: function(data) {
							if(data.result == "success") {
								Prompt.alert("删除提示", "已删除！");
								location.href = location.href;
							} else {
								Prompt.alert("删除提示", "删除失败！");
							}
						},
						error: function() {
							Prompt.alert("删除提示", "服务器无响应，请刷新页面后重试！");
						}
					});
				}
				Prompt.confirm("提示", "确认要删除该信息吗?删除后无法恢复", delFunc);
			}
		</script>
	</body>

</html>